//
//  BigNewsImageView.m
//  WXMovie
//
//  Created by mac106 on 16/4/1.
//  Copyright © 2016年 无限互联. All rights reserved.
//

#import "BigNewsImageView.h"

@implementation BigNewsImageView

// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
//    self.frame = [UIScreen mainScreen].bounds;
//    
//    _image = [[UIImageView alloc] initWithFrame:CGRectMake(0, kScreenHeight / 2 -100, kScreenWidth, 200)];
//    [self addSubview:_image];
//    
//    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//    button.frame = [UIScreen mainScreen].bounds;
//    [self insertSubview:button aboveSubview:_image];
//    button.backgroundColor = [UIColor clearColor];
//    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    
    
}

- (instancetype)init {
    self = [super init];
    if (self) {
        self.frame = [UIScreen mainScreen].bounds;
        
        _image = [[UIImageView alloc] initWithFrame:CGRectMake(0, kScreenHeight / 2 -100, kScreenWidth, 200)];
        [self addSubview:_image];
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        button.frame = [UIScreen mainScreen].bounds;
        [self insertSubview:button aboveSubview:_image];
        button.backgroundColor = [UIColor clearColor];
        [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        self.hidden = YES;
    }
    return self;
}

- (void)setImageName:(NSString *)string {
    
    [_image sd_setImageWithURL:[NSURL URLWithString:string]];
    self.hidden = NO;
}

- (void)buttonAction:(UIButton *)button {
    
    button.selected = !button.selected;
    if (button.selected) {
        self.hidden = YES;
    }else {
        self.hidden = NO;

    }
    
}

@end
